#include "mainui.h"

MainUI::MainUI()
{
    // 初始化
    this->setResizeMode(QQuickWidget::SizeRootObjectToView);
    this->setSource(QUrl("qrc:/main.qml"));

    rootObj = this->getRootObject();
    if(rootObj){
        connect(rootObj, SIGNAL(prevPage()), this, SIGNAL(prevPage()));
        connect(rootObj, SIGNAL(nextPage()), this, SIGNAL(nextPage()));
        connect(rootObj, SIGNAL(opening()), this, SIGNAL(opening()));
        connect(rootObj, SIGNAL(program()), this, SIGNAL(program()));
        connect(rootObj, SIGNAL(maintenance()), this, SIGNAL(maintenance()));
        connect(rootObj, SIGNAL(setting()), this, SIGNAL(setting()));
    }
}

MainUI::~MainUI()
{}

/**
 * @brief getContext 获取qmlcontext
 * @return qmlContext
 */
QQmlContext* MainUI::getContext() const
{
    return this->rootContext();
}

/**
 * @brief getRootObject 获取rootObject
 * @return rootObject
 */
QObject* MainUI::getRootObject() const
{
    return (QObject*)this->rootObject();
}
